package com.weetop.aklyscan.utils;

import android.content.Context;
import android.graphics.Color;
import android.view.View;

import com.bigkoo.pickerview.TimePickerView;

import java.util.Calendar;
import java.util.Date;

public class MyTimePicker1 {
    TimePickerView pvTime;

    public TimePickerView selectTime(Context context, Calendar sDate, Calendar eDate) {
        Calendar selectedDate = Calendar.getInstance();

        pvTime = new TimePickerView.Builder(context, new TimePickerView.OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {//选中事件回调
                if (mOnSelectListener != null) {
                    mOnSelectListener.onSelect(date, v); // 2
                }
            }
        })
                //年月日时分秒 的显示与否，不设置则默认全部显示
                .setType(new boolean[]{true, true, true, false, false, false})
                .setLabel("年", "月", "日", "", "", "")
                .isCenterLabel(true)
                .setDividerColor(Color.DKGRAY)
                .setContentSize(16)
                .setDate(selectedDate)
                .setTitleText("时间选择")
                .setCancelText("取消")
                .setSubmitText("确定")
                .setRangDate(sDate, eDate)
                .setDecorView(null)
                .build();
        return pvTime;

    }

    private OnSelectListener mOnSelectListener;

    public void setOnSelectListener(OnSelectListener mOnSelectListener) {
        this.mOnSelectListener = mOnSelectListener;
    }

    public interface OnSelectListener {
        void onSelect(Date date, View v);
    }

}
